<template>
	<view class="box">
		<view class="result">
			<image class="_img" :src="src" mode="aspectFit" style="width: 200rpx;"></image>
			<view class="resList">
				<view class="itemBlock" v-for="(item,index) in topFives">
					<view class="score">
						匹配度:{{ (item.score * 100).toFixed(2) }}%
					</view>
					<view class="calorie">
						名称:{{item.category}}
					</view>
					<view class="category">
						热量:{{item.calorie == "UNKNOWN"?"未知":item.calorie+" 千卡"}} 
					</view>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 图像
				src: "/static/logo.png",
				// 图像识别结果
				topFives: [{
					// 匹配度
					score: 0.5590515,
					// 热量
					calorie: "116",
					category: "米饭"
				}, {
					// 匹配度
					score: 0.5590515,
					// 热量
					calorie: "116",
					category: "米饭"
				}],
			};
		},
		onLoad: function(options) {
			// 获取拍摄的图片
			console.log(options.src)
			this.src = options.src
			// 从内存获取topFives
			var result = wx.getStorageSync('result');
			if(result != null){
				this.topFives = result
			}
		}
	}
</script>

<style lang="scss">
	.box {

		.result {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;

			._img {
				text-align: center;
			}

			.resList {
				width: 80%;
				display: flex;
				flex-direction: column;
				align-items: center;
				gap: 10px;

				.itemBlock {
					height: 300rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					border: 2rpx solid limegreen;
					border-radius: 20rpx;
					background-color: limegreen;
					width: 100%;
				}

				.itemBlock {
					.score {
						color: white;
						font-size: 50rpx;
						font-weight: 600;
						margin: 15rpx 0;
					}

					.calorie {
						color: white;
						font-size: 50rpx;
						font-weight: 600;
						margin: 15rpx 0;
					}

					.category {
						color: white;
						font-size: 50rpx;
						font-weight: 600;
						margin: 15rpx 0;
					}
				}
			}
		}
	}
</style>